home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Graphics;
- import java.awt.Image;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- class HrefButtonArea extends ImageMapArea {
- URL anchor;
- Image upImage;
- Image downImage;
- boolean pressed = false;
- int border = 5;
-
- public void handleArg(String arg) {
- try {
- this.anchor = new URL(super.parent.getDocumentBase(), arg);
- } catch (MalformedURLException var2) {
- this.anchor = null;
- }
-
- if (this.border * 2 > super.W || this.border * 2 > super.H) {
- this.border = Math.min(super.W, super.H) / 2;
- }
-
- }
-
- public void makeImages() {
- this.upImage = super.parent.getHighlight(super.X, super.Y, super.W, super.H, new ButtonFilter(false, super.parent.hlpercent, this.border, super.W, super.H));
- this.downImage = super.parent.getHighlight(super.X, super.Y, super.W, super.H, new ButtonFilter(true, super.parent.hlpercent, this.border, super.W, super.H));
- }
-
- public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
- if (img == (this.pressed ? this.downImage : this.upImage)) {
- return super.parent.imageUpdate(img, infoflags, x + super.X, y + super.Y, width, height);
- } else {
- return img == this.downImage || img == this.upImage;
- }
- }
-
- public void highlight(Graphics g, boolean on) {
- if (on) {
- ((ImageMapArea)this).setHighlight(this.pressed ? this.downImage : this.upImage);
- }
-
- super.highlight(g, on);
- ((ImageMapArea)this).showStatus(on && this.anchor != null ? "Go To " + this.anchor.toExternalForm() : null);
- }
-
- public void press() {
- super.parent.repaint();
- this.pressed = true;
- }
-
- public void lift(int x, int y) {
- this.pressed = false;
- super.parent.repaint();
- if (((ImageMapArea)this).inside(x, y) && this.anchor != null) {
- ((ImageMapArea)this).showDocument(this.anchor);
- }
-
- }
-
- public HrefButtonArea() {
- }
- }
-